package org.sport.repository;

import org.sport.model.entityModel.ActivitytableEntity;
import org.sport.model.entityModel.ParacttableEntity;
import org.sport.model.entityModel.SporthistorytableEntity;
import org.sport.model.entityModel.UsertableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface ParacttableRepository extends JpaRepository<ParacttableEntity,Integer> {





    @Transactional
    @Query("select paract from ParacttableEntity paract where paract.usertableByUserId =?1")
    public List<ParacttableEntity> findByUserId(UsertableEntity usertableEntity);

    @Modifying
    @Transactional
    @Query("update ParacttableEntity paract set " +
            "paract.status=:qStatus" +
            " where paract.activitytableByActId=:qActivitytableByActId")
    public void updateParActByActId(@Param("qStatus") String status,
                                        @Param("qActivitytableByActId") ActivitytableEntity activitytableByActId);
}
